package com.situ.day5.cal;

import org.junit.Test;

import com.situ.day5.Person;
import com.situ.day5.Student;

public class CalDemo {

	public static void main(String[] args) {
		Add add = new Add(3, 5);
		int result1 = add.getResult();
		System.out.println(result1);
		Mul mul = new Mul(3, 5);
		int result2 = mul.getResult();
		System.out.println(result2);

		// 多态
		// 你继承谁你就是谁，所以new出来的子类对象那个可以赋值给父类变量
		Person person = new Student();// 学生就是人
		AbstractCal cal = new Add(3, 5);
		int result3 = cal.getResult();
		System.out.println(result3);// 8
		cal = new Mul(3, 5);// 让父类变量重新指向了new出来的Mul子类对象
		int result4 = cal.getResult();
		System.out.println(result4);// 15
	}
	
	@Test
	public void test44() {
		AbstractCal cal = new AbstractCal(3, 5);
		int result = cal.getResult();
		System.out.println(result);
	}
	
	
	
	

}
